var time = sessionStorage.time;
if (typeof (time) == "undefined") {
	var timeTest = new Date().getTime();
	var timeobj = {
		timebegin : timeTest
	};
	sessionStorage.time = JSON.stringify(timeobj);
}

function EbeimService() {
    
    this.login = function(data, success, error) {
    	ebeimAjax({
            url: "/rest/login",
            data: JSON.stringify(data), // '{"name":"' + model.name + '"}',  
            contentType: 'application/json;charset=UTF-8',
            dataType: 'text',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.getComputerMessage = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/computer_message/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.noAuthorization = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/no_authorization/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getCpuRate = function(data, success, error){
    	$.ajax({
            url: "/rest/monitor/cpuRate",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getMessageCode = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/short_message/send",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.oncePasswordUpdate = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/short_message/update_password",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.keyNoBindCheck = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/key_no_bind/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }

    this.keyBindCheck = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/key_bind/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }

    this.authorizationCodeNoBindCheck = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/authorization_code_no_bind/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }

    this.authorizationCodeBindCheck = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/authorization_code_bind/check",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getForgetUser = function(data, success, error){
    	ebeimAjax({
            url: "/rest/noIntercept/user/username",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getFirstPageStatics = function(data, success, error){
    	ebeimAjax({
            url: "/rest/first_page/total",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getDataSourcesByPage = function(data, success, error){
    	$.ajax({
            url: "/api/download/dataSourceList",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: function(data){
            	plugin.msgtip({type:"e",msg:"获取数据源列表失败!"});
            }
        });
    }
    
    this.getUploadProcessBar = function(data, success, error){
    	$.ajax({
            url: "/rest/upload/process/bar",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.getUploadProcessBarAll = function(data, success, error){
    	$.ajax({
            url: "/rest/upload/process/bar/all",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.deleteUploadProcessBar = function(data, success, error){
    	$.ajax({
            url: "/rest/upload/process/bar/delete",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.addDataSource = function(data, success, error){
    	ebeimAjax({
            url: "/api/datasources/save",
            data: JSON.stringify(data),
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            type: "POST",
            loadingTxt:"请求中，请稍候...",
            success: success,
            error: error
        });
    }
    
    this.getSystemDirs = function(data, success, error){
    	ebeimAjax({
            url: "/api/system/dirs",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.sendMobileCode = function(data, success, error){
    	ebeimAjax({
            url: "/rest/send/mobilecode",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.backup = function(data, success, error){
    	ebeimAjax({
            url: "/rest/backup",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getDataSource = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasources/"+data,
            data: {},
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getFileList = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasources/files",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    //2015年11月11日17:00:25
    this.getBackuplogs = function(data, success, error){
    	ebeimAjax({
            url: "/rest/backlog/list",
            data: JSON.stringify(data),
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.getFileChangeLog = function(data, success, error){
    	ebeimAjax({
            url: "/rest/filechanglog/list",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.recoveryFile = function(data, success, error){
    	ebeimAjax({
            url: "/rest/recovery",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getDownloadProcessBar = function(data, success, error){
    	$.ajax({
            url: "/rest/downlaod/process/bar",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    	
    }
    
    this.deleteDownloadProcessBar = function(data, success, error){
    	$.ajax({
            url: "/rest/download/process/bar/delete",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.deleteDownloadProcessBarByNid = function(data, success, error){
    	ebeimAjax({
            url: "/rest/download/process/bar/delete/nid",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.backup = function(data, success, error){
    	ebeimAjax({
            url: "/rest/backup",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.safeBoxInfo = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasource/safe_box/info",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.updataStatusMany = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasource/update/status",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    //----------------------邪恶的分割线--------------------------
    this.getMenuTree = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasource/menu",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
            
    this.getMonitorDatasource = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/datasources/list",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getMonitorPlan = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/datasources/plan",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getMonitor = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/userInfo",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getMonitorAlert = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/warnList",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    //获取目前的系统参数
    this.getSystemInfo = function(data, success, error){
    	ebeimAjax({
            url: "/rest/systemSet/getSysInfo",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    //设置系统变量
    this.setSystemInfo = function(data, success, error){
    	ebeimAjax({
            url: "/rest/systemSet/sysInfo",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getUserInfo = function(data, success, error){
    	ebeimAjax({
            url: "/api/userinfo",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
   //改变服务系统参数 
    this.changeServiceParam = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/changeServiceParam",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    //改变服务状态 
    this.changeService = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/changeService",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    
    
    this.getMonitorNetWorkMonitor = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/net_work_monitor",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getPushMessage = function(data, success, error){
    	$.ajax({
            url: "/rest/pushmessage/list",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.createVersionTreeFolder = function(data, success, error){
    	ebeimAjax({
            url: "/rest/version/tree/createfolder",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.importDs = function(data, success, error){
    	ebeimAjax({
            url: "/rest/datasource/import",
            data: JSON.stringify(data),
            contentType: 'application/json;charset=UTF-8',
            dataType: 'json',
            type: "POST",
            loadingTxt:"正在构建目录结构，请稍候...",
            success: success,
            error: error
        });
    }
    
    
    this.getServiceStatus = function(data, success, error){
    	$.ajax({
            url: "/rest/monitor/getServiceStatus",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    this.getMonitorDetailPlan = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/getDetailPlan",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getUpDownloadFaileds = function(data, success, error){
    	$.ajax({
            url: "/rest/updownload/failed/files",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.upDownloadRetry = function(data, success, error){
    	ebeimAjax({
            url: "/rest/updownload/failed/files/tryagain",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.deleteUpDownloadFailedFiles = function(data, success, error){
    	$.ajax({
            url: "/rest/updownload/failed/files/delete",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.countByType = function(data, success, error){
    	$.ajax({
            url: "/rest/updownload/failed/count/type",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.openFolder = function(data, success, error){
    	ebeimAjax({
            url: "/rest/Import/open/folder",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.openFolder = function(data, success, error){
    	ebeimAjax({
            url: "/rest/Import/open/folder",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.openFile = function(data, success, error){
    	ebeimAjax({
            url: "/rest/Import/open/file",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.getDownloadProcessBarAll = function(data, success, error){
    	$.ajax({
            url: "/rest/download/process/bar/all",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.monitorStopService = function(data, success, error){
    	ebeimAjax({
            url: "/rest/monitor/stopService",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }
    
    this.unlock = function(data, success, error){
    	ebeimAjax({
            url: "/rest/unlock",
            data: data,
            dataType: 'json',
            type: "POST",
            success: success,
            error: error
        });
    }
    
    this.getLoginLog = function(data, success, error){
    	ebeimAjax({
            url: "/rest/login_log/list",
            data: data,
            dataType: 'json',
            type: "GET",
            success: success,
            error: error
        });
    }

}
